$( document ).ready(function() {
	
  /*
  if ($('#trust-form').length > 0) {
    var trustFormWrap = $('<div/>',{id:'trust-form-wrap',css:{display:'none'}});
    $('#mainbody section.content').append(trustFormWrap);
    $('#trust-form').appendTo(trustFormWrap);
    
    $('.btnShowForm').on('click', function() {
      console.log('go'); 
      $.colorbox({
        html: trustFormWrap.html(),
        cbox_complete: function() {
        console.log('cbox_complete'); 
          trustFormWrap.empty();
        }
      });
    });
    
    $('#trust-form form').submit(function(event) {
      console.log('submit'); 
      event.preventDefault();
      return false;
    });
  }
  */
  // $.post(ajax_object.ajaxurl, {
			// action: 'ajax_action',
			// post_id: '9'
		// }, function(data) {
			// console.log(data); // alerts 'ajax submitted'
		// });
  
	// add class "collapsed" at the first time
	if ($(".panel-title a").length>0) {
		$(".panel-title a").addClass("collapsed");
	}
	
	// apply ColorBox for all "colorbox" class
	$('a.colorbox').colorbox();
	
	// scroll to the target right after finishing loading
	var hash = document.URL.substring(document.URL.indexOf("#")+1);
	if (hash.length > 0 && hash!=document.URL) {
		var archor = hash;
		if (hash.substring(0,1)!='.') archor = '#'+archor;
		$('html,body').animate({
			scrollTop: $(archor).offset().top
		}, 1000);
	}

	// smooth scroll
	$('#mainmenu a[href*=#]:not([href=#]), .footermenu a ').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
    
    if(this.hash.substring(0,1)=='#') {
      var target = $(this.hash.slice(1));
    } else {
      var target = $(this.hash);
    }
    
			target = target.length ? target : $('#' + this.hash.slice(1));
			if (target.length) {
				$('html,body').animate({
					scrollTop: target.offset().top
				}, 1000);
				return false;
			}
		}
	});
  // bullshit
  if (!$('body').hasClass('home')) {
    $('html,body').animate({
      scrollTop: $('#breadcrumb').offset().top
    }, 1000);
  }
});